/**
 * 实名认证
 */
define(function (require, exports, module) {


    var UI = require("js/UI"),
        uiTip=require("ui/tip");
    var $homeCnt = $("#home .cnt");



    var reg_idNumber=/^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/

    var $userForm = $homeCnt.find(".userForm"),
        $userName = $userForm.find(".userName"),
        $name = $userForm.find(".name"),
        $idNumber = $userForm.find(".idNumber")


    $homeCnt.find(".bindTit.unbind a").unbind("click.name").bind("click.name", function () {
        $userForm.fadeIn();
    })

    $userForm.find("button[type=submit]").unbind("click.sub").bind("click.sub", function () {

        var _userName = $.trim($userName.val()),
            _name = $.trim($name.val()),
            _idNumber = $.trim($idNumber.val())

        if (!_userName) {
            //UI.tooltip("error", "请输入用户名");
            uiTip($userName, "请输入用户名", "right").show();
            $userName.focus();
            return false
        }else{
            if(_userName.length<6 ||_userName.length>12){
                //UI.tooltip("error", "用户名大于6 小于12个字符");
                uiTip($userName, "用户名大于6 小于12个字符", "right").show();
                $userName.focus();
                return false
            }
        }
        if (!_name) {
            //UI.tooltip("error", "请输入真实姓名");
            uiTip($name, "请输入真实姓名", "right").show();
            $name.focus();
            return false
        }else{
            if(_name.length<2){
                //UI.tooltip("error", "输入姓名小于2个字符");
                uiTip($name, "输入姓名小于2个字符", "right").show();
                $name.focus();
                return false
            }
        }
        if (!_idNumber) {
            //UI.tooltip("error", "请输入身份证号");
            uiTip($idNumber, "请输入身份证号", "right").show();
            $idNumber.focus();
            return false
        }else{
            if(_idNumber.match(reg_idNumber)){
                //UI.tooltip("error", "请输入正确的身份证号格式");
                uiTip($idNumber, "请输入正确的身份证号格式", "right").show();
                $idNumber.focus();
                return false
            }
        }
    });


})